#include "WZmqServer.h"
//#include "BoostLog.h"
ZmqServer::ZmqServer(QObject* parent)
	: QObject(parent)
	, stop_thread(false)
	, heart_timer(nullptr)
	, context(nullptr)
	, publisher(nullptr)
{

}

void ZmqServer::SlotStartServer()
{
	//int ret = -1; //函数返回值
	//context = zmq_ctx_new();
	//zmq_ctx_set(context, ZMQ_MAX_SOCKETS, 1); 
	//publisher = zmq_socket(context, ZMQ_PUB);
	//ret = zmq_bind(publisher, "tcp://169.254.24.202:8689");
	////ret = zmq_bind(publisher, "tcp://127.0.0.1:8689");
	//if (ret != 0)
	//{
	//	WriteLog("***zmq bind failed***");
	//	return;
	//}

	//while (!stop_thread) 
	//{
	//	// 发送心跳消息
	//	std::string reply_message = "heartbeat";
	//	int ret = zmq_send(publisher, reply_message.c_str(), reply_message.size(), 0);
	//	std::this_thread::sleep_for(std::chrono::milliseconds(3000));
	//}
}

void ZmqServer::SendToClient(const std::string& message)
{
	/*std::string reply_message = "pcb come";
	int ret = zmq_send(publisher, reply_message.c_str(), reply_message.size(), 0);
	WriteLog("zmq send return:%d", ret);*/
}

void ZmqServer::SlotStopServer()
{
	//stop_thread = true;
	////关闭套接字、销毁上下文
	//zmq_close(publisher);
	//zmq_ctx_destroy(context);
}